﻿@model CustomerRoleModel

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)

<script type="text/javascript">
    $(document).ready(function () {
        toggleRemoveButton();
    });

    function toggleRemoveButton() {
        if ($('#@Html.FieldIdFor(model => model.PurchasedWithProductId)').val() > 0) {
            $('#purchased-with-product-name-remove').show();
        }
        else {
            $('#purchased-with-product-name-remove').hide();
        }
    }
</script>
<table class="adminContent">
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Name)
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.SystemName)
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.SystemName)
            @Html.ValidationMessageFor(model => model.SystemName)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.FreeShipping):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.FreeShipping)
            @Html.ValidationMessageFor(model => model.FreeShipping)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.TaxExempt):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.TaxExempt)
            @Html.ValidationMessageFor(model => model.TaxExempt)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Active):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Active)
            @Html.ValidationMessageFor(model => model.Active)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.IsSystemRole):
        </td>
        <td class="adminData">
            @Model.IsSystemRole.ToString()
            @Html.HiddenFor(model => model.IsSystemRole)
            @Html.ValidationMessageFor(model => model.IsSystemRole)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.PurchasedWithProductId):
        </td>
        <td class="adminData">
            @Html.HiddenFor(model => model.PurchasedWithProductId)
            <span id="purchased-with-product-name">@Model.PurchasedWithProductName</span>
            @Html.ValidationMessageFor(model => model.PurchasedWithProductId)
            <input type="submit" value=@T("Admin.Customers.CustomerRoles.Fields.PurchasedWithProduct.Choose") onclick="javascript:OpenWindow('@(Url.Action("AssociateProductToCustomerRolePopup", "CustomerRole", new { productIdInput = Html.FieldIdFor(model => model.PurchasedWithProductId), productNameInput = "purchased-with-product-name", btnId = "btnRefreshPurchasedWithProduct" }))', 800, 800, true); return false;" class="k-button" />
            <input type="submit" id="purchased-with-product-name-remove" value=@T("Admin.Customers.CustomerRoles.Fields.PurchasedWithProduct.Remove") class="k-button" />
            <input type="submit" id="btnRefreshPurchasedWithProduct" name="btnRefreshPurchasedWithProduct" style="display: none" />
            <script type="text/javascript">
                $(document).ready(function () {
                    $('#purchased-with-product-name-remove').click(function () {
                        $('#purchased-with-product-name').text('');
                        $("#@Html.FieldIdFor(model => model.PurchasedWithProductId)").val(0);
                        toggleRemoveButton();
                        //return false to don't reload a page
                        return false;
                    });

                    $('#btnRefreshPurchasedWithProduct').click(function () {
                        toggleRemoveButton();

                        //return false to don't reload a page
                        return false;
                    });
                });
            </script>

        </td>
    </tr>
</table>
